package day15.OneStageSystem;
//话痨套餐类
public class TalkPackage extends ServicePackage implements CallService,SendService,NetService{
    public TalkPackage(double price){
        super.price = price;
    }
    //电话方法
    public int call(int minCount, MobileCard card) {
        card.setRealTalkTime(minCount+card.getRealTalkTime());
        int flag = card.getRealTalkTime();
        if (flag>500){
            double beyond = (flag-500)*0.2;
            if ((card.getMoney()-beyond)>0){
                card.setMoney(card.getMoney()-beyond);
                card.setConsumerAmount(card.getConsumerAmount()+beyond);
            }else {
                System.out.println("余额不足以支持使用此次使用,请充值!");
            }
        }
        return Math.max((500-card.getRealTalkTime()),0);
    }
    //流量方法
    public int netPlay(int flow, MobileCard card) {
        card.setRealFlow(flow+card.getRealFlow());
        int flag = card.getRealFlow();
        double beyond = flag*0.1;
        if ((card.getMoney()-beyond)>0){
            card.setMoney(card.getMoney()-beyond);
            card.setConsumerAmount(card.getConsumerAmount()+beyond);
        }else {
            System.out.println("余额不足以支持使用此次使用,请充值!");
        }
        return 0;
    }
    //短信方法
    public int send(int count, MobileCard card) {
        card.setRealSMSCount(count+card.getRealSMSCount());
        int flag = card.getRealSMSCount();
        if (flag>30){
            double beyond = (flag-30)*0.1;
            if ((card.getMoney()-beyond)>0){
                card.setMoney(card.getMoney()-beyond);
                card.setConsumerAmount(card.getConsumerAmount()+beyond);
            }else {
                System.out.println("余额不足以支持使用此次使用,请充值!");
            }
        }
        return Math.max((30-card.getRealSMSCount()),0);
    }
    //展示方法
    public void showInfo() {
        System.out.println("话痨套餐:每月通话时长500分钟,每月无上网流量,每月短信30条,套餐费用58元");
    }
}
